package com.zhaoyang.utils;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;

import java.util.ArrayList;
import java.util.List;

public class YangGuiUtils {

    // 创建菜单方法
    public static void openMainMenu(Player player) {
        Inventory menu = Bukkit.createInventory(null, 54, "主菜单");
        ItemStack pane = new ItemStack(Material.getMaterial("STAINED_GLASS_PANE"));
        // 设置边框为玻璃
        for (int i = 0; i < 9; i++) {
            menu.setItem(i, pane);
            menu.setItem(i + 45, pane);
        }

        for (int i = 9; i < 45; i += 9) {
            menu.setItem(i, pane);
            menu.setItem(i + 8, pane);
        }
        // 添加按钮
        ItemStack playerHead = new ItemStack(Material.getMaterial("SKULL_ITEM"), 1, (short) 3);
        // 获取SkullMeta
        SkullMeta skullMeta = (SkullMeta) playerHead.getItemMeta();
        List<String> loreList = new ArrayList<>();
        loreList.add("玩家信息:" + player.getName());
        loreList.add(ChatColor.YELLOW + "游戏金币：" + 100.00);
        loreList.add("称号：超级管理员");
        skullMeta.setLore(loreList);
        playerHead.setItemMeta(skullMeta);
        menu.setItem(13, playerHead);
        ItemStack button2 = new ItemStack(Material.GOLDEN_APPLE);
        menu.setItem(20, button2);

        // 打开菜单
        player.openInventory(menu);
    }
}
